import junit.framework.TestCase;
import org.junit.Test;
public class StringBufferDemoTest extends TestCase {
    StringBuffer a = new StringBuffer("abcdefg");
    String testStr="a,b,c,d,e,f";
    @Test
    public void testNormalcharAt(){       //charAt正常情况
        assertEquals('b',a.charAt(1));
        assertEquals('c',a.charAt(2));
        assertEquals('d',a.charAt(3));
    }
    @Test
    public void testBoundarycharAt(){     //charAt边界情况
        assertEquals('a',a.charAt(0));
        assertEquals('g',a.charAt(6));
    }
    @Test
    public void testExceptionscharAt(){     //charAt异常情况
        //assertEquals('x',a.charAt(0));
        //assertEquals('y',a.charAt(6));
        //assertEquals('z',a.charAt(6));
    }
    @Test
    public void testNormalsplit() {        //split正常情况
        String [] results =  testStr.split(",");
        assertEquals("b",results[1]);
        assertEquals("c",results[2]);
        assertEquals("d",results[3]);
    }
    @Test
    public void testBoundarysplit() {      //split边界情况
        String [] results =  testStr.split(",");
        assertEquals("a",results[0]);
        assertEquals("f",results[5]);
    }
    @Test
    public void testExceptionssplit() {        //split异常情况
        String [] results =  testStr.split(",");
        //assertEquals("A",results[0]);
        //assertEquals("B",results[1]);
        //assertEquals("C",results[2]);
    }
}
